<{include file="tpl/admin/header.html"}>
<script type="text/javascript">
$(document).ready(function(){ // 当页面加载完毕的时候
	// 例子三
	$("#ex3button").click(function(){ // "提交"按钮被点击
		// 构造发送的数据，请注意如果获取表单各项的值
		var formdata = {
			'id' : $('#id').val(),
			'pid' : $('#pid').val(),
			'cname' : $('#cname').val(),
			'seq' : $('#seq').val(),
			'ismenu' : $('#ismenu').val(),
			'part' : $('#part').val(),
			'another' : $('#another').val(),
			'title' : $('#title').val(),
			'keywords' : $('#keywords').val(),
			'description' : $('#description').val()
		};
		var id  = $('#id').val();  // 根据有没有id 判断是编辑还是增加
		if(id == '')
		{
			// 用$.post发送数据
			$.post('<{spUrl c=categorylist a=adddata}>', formdata, function(result){
				$('#resulttable').append(result); // 返回的数据直接追加到resulttable表格的后面
				feedback(result,id);
			});
		}
		else
		{
		   	// 用$.post发送数据
			$.post('<{spUrl c=categorylist a=editdata}>', formdata, function(result){
				$('#resulttable').append(result); // 返回的数据直接追加到resulttable表格的后面
			    feedback(result,id);
			});	
		}
		
	});
});

function del(id){
		$.get('<{spUrl c=categorylist a=deldata}>', 'id='+id, function(result){
			$('#ex1result').html(result); // 返回的数据直接显示在id=ex1result的span中。
			if(result == 1)
			{alert('删除成功!!');}else{alert('删除失败!!')}
			window.location.reload(); 
		});
}
</script>
<div class="breadcrumbs">
	<div class="container-fluid">
		<ul class="bread pull-left">
			<li>
				<a href="index.php?c=manage&a=index"><i class="icon-home icon-white"></i></a>
			</li>
			<li>
				<a href="index.php?c=categorylist&a=index&t=message">
					分类管理
				</a>
			</li>
		</ul>

	</div>
</div>
<div class="main">
    <{include file="tpl/admin/left.html"}>
	<div class="container-fluid">
		<div class="content">
			<div class="row-fluid">
				<div class="span12">
					<div class="box">
						<div class="box-head tabs">
							<h3>分类管理 | <a href="index.php?c=categorylist&a=index&t=message">添加</a></h3>
							<ul class='nav nav-tabs'>
								<li class='active'>
									<a href="#basic" data-toggle="tab">Basic</a>
								</li>
								<li>
									<a href="#nohead" data-toggle="tab">No header</a>
								</li>
							</ul>
						</div>
						<div class="box-content box-nomargin">
							<div class="tab-content">
									<div class="tab-pane active" id="basic">
										<table class='table table-striped dataTable table-condensed table-bordered'>
                                        	  <!-- <thead> -->
                                                <th>排序</th>
                                                <th>分类名</th>
                                                <th>菜单显示</th>
                                                <th>栏目显示</th>
                                                <th>别名</th>
                                                <th>操作</th>
                                            <!--  </thead> -->
											<tbody>
                                              <{foreach item=resultsname from=$results key=enname}>
                                                <tr>
                                                 <td><{$resultsname.seq}></td>
                                                 <td><{$resultsname.cname}></td>
                                                <{if $resultsname.ismenu == '1'}>
                                                   <td>是</td>
                                                 <{else}>
                                                  <td> 否</td>
                                                 <{/if}>
                                                 <{if $resultsname.part == '1'}>
                                                   <td>是</td>
                                                 <{else}>
                                                  <td> 否</td>
                                                 <{/if}>
                                                 <td><{$resultsname.another}></td>
                                                 <td><a href="index.php?c=categorylist&a=index&t=message&id=<{$resultsname.id}>#mao">编辑</a> | <a href="javascript:del(<{$resultsname.id}>);">删除</a></td> 
                                                </tr>
                                              <{/foreach}>
											</tbody>
										</table>
									</div>
									<div class="tab-pane" id="nohead">
										<table class='table table-striped dataTable dataTable-noheader table-bordered'>
											<thead>
												<tr>
                                                <th>编号</th>
                                                <th>分类名</th>
                                                <th>菜单显示</th>
                                                <th>栏目显示</th>
                                                <th>排序</th>
                                                <th>操作</th>												
                                                </tr>
											</thead>
											<tbody>
                                              <{foreach item=resultsname from=$results key=enname}>
                                                <tr>
                                                 <td><{$resultsname.id}></td> 
                                                 <td><{$resultsname.cname}></td>
                                                 <{if $resultsname.ismenu == '1'}>
                                                   <td>是</td>
                                                 <{else}>
                                                  <td> 否</td>
                                                 <{/if}>
                                                 <{if $resultsname.part == '1'}>
                                                   <td>是</td>
                                                 <{else}>
                                                  <td> 否</td>
                                                 <{/if}>
                                                 <td><{$resultsname.seq}></td>
                                                 <td><a href="index.php?c=categorylist&a=index&t=message&id=<{$colorname.id}>">编辑</a> | <a href="javascript:del(<{$colorname.id}>);">删除</a></td> 
                                                </tr>
                                              <{/foreach}>											
                                           </tbody>
										</table>
									</div>

							</div>
						</div>
					</div>
				</div>
			</div>
            <div class="row-fluid">
				<div class="span12">
					<div class="box">
						<div class="box-head">
							<a href="" name="mao"></a>
                           <{if $id != 0}>
                              <h3>编辑数据</h3>
                           <{else}>
                              <h3>增加数据</h3>
                           <{/if}>
						</div>
						<div class="box-content">
							<form action="#" class='validate form-horizontal'>
								<div class="control-group">
									<label for="req" class="control-label">上级分类：</label>
									<div class="controls">
                                       <select name="pid" id="pid">
                                           <option selected value="0">根目录</option>
                                           <{foreach item=resultsname from=$results key=enname}>
                                             <{if $pid == $resultsname.id}>
                                                <option selected value="<{$resultsname.id}>"><{$resultsname.cname}></option>
                                             <{else}>
                                                <option value="<{$resultsname.id}>"><{$resultsname.cname}></option>
                                             <{/if}>
                                           <{/foreach}>
                                        </select>
                                  </div>
								</div>
                                <div class="control-group">
                                   <label for="req" class="control-label">分类名称：</label>
                                   <div class="controls">
                                   <input type="text" name="cname" id="cname" value="<{$cname}>">
								   <span></span>
                                  </div>
                                </div>
                                
                                <div class="control-group">
                                   <label for="req" class="control-label">排序：</label>
                                   <div class="controls">
                                   <input type="text" name="seq" id="seq" value="<{$seq}>">
								   <span></span>
                                  </div>
                                </div>
                                
                               <div class="control-group">
                                   <label for="req" class="control-label">菜单显示：</label>
                                   <div class="controls">
                                    <select name="ismenu" id="ismenu">
                                         <{if $ismenu == '1'}>
                                            <option selected value="1">是</option>
                                            <option value="0">否</option>
                                         <{else}>
                                            <option selected value="0">否</option>
                                            <option value="1">是</option>
                                         <{/if}>
                                    </select>
                                  </div>
                                </div>
                                
                                <div class="control-group">
                                   <label for="req" class="control-label">栏目显示：</label>
                                   <div class="controls">
                                    <select name="part" id="part">
                                         <{if $part == '1'}>
                                            <option selected value="1">是</option>
                                            <option value="0">否</option>
                                         <{else}>
                                            <option selected value="0">否</option>
                                            <option value="1">是</option>
                                         <{/if}>
                                    </select>
                                  </div>
                                </div>
                               
                                <div class="control-group">
                                   <label for="req" class="control-label">别名：</label>
                                   <div class="controls">
                                   <input type="text" name="another" id="another" value="<{$another}>">
								   <span></span>
                                  </div>
                                </div>
                                
                               <div class="control-group">
                                   <label for="req" class="control-label">自定义标题：</label>
                                   <div class="controls">
                                   <input type="text" name="title" id="title" value="<{$title}>">
								   <span></span>
                                  </div>
                                </div>
                                
                              <div class="control-group">
                                   <label for="req" class="control-label">自定义关键字：</label>
                                   <div class="controls">
                                   <input type="text" name="keywords" id="keywords" value="<{$keywords}>">
								   <span></span>
                                  </div>
                                </div>
                                
                             <div class="control-group">
                                   <label for="req" class="control-label">自定义说明：</label>
                                   <div class="controls">
                                   <input type="text" name="description" id="description" value="<{$description}>">
								   <span></span>
                                  </div>
                                </div>
                              
						<div class="form-actions">
								  <input type="button" id="ex3button" value="提交" class='btn btn-primary'>
                                  <input type="hidden" name="id" id="id" value="<{$id}>">
						</div>
							</form>
						</div>
					</div>
				</div>
                
		</div>	
	</div>
</div>	
<{include file="tpl/admin/footer.html"}>